home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / shareware / share_41 / assembler / examples / dec_bin < prev    next >
Text File  |  1991-05-15  |  999b  |  41 lines

  1. ; NAME       dec_bin
  2. ; PURPOSE    converts the decimal number1 to a binary bit pattern in text1
  3. ; DESIGN     
  4. ;            load number1
  5. ;            for i <- 31 down to 0
  6. ;               asl number1
  7. ;               if carry = 1
  8. ;               then
  9. ;                 character = '1'
  10. ;               else
  11. ;                 character = '0'
  12. ;               endif
  13. ;               place character at end of text1
  14. ;               increment text pointer
  15. ;             end for
  16. ;             place control character at end of text1
  17.  
  18. ; NOTE
  19.  
  20. ;            r1 stores the address of number to be converted
  21. ;            r4 stores the address of the converted string
  22. ;            r6 is loaded with the number to be converted
  23. ;            r7 is used as a loop counter
  24. ;            r8 holds a '1' or '0' depending on the carry flag
  25.  
  26.  
  27. ldr r6, [r1]
  28. mov r7, #31
  29. .loop
  30.    movs r6, r6, lsl #1
  31.    movcc r8, #48
  32.    movcs r8, #49
  33.    strb  r8, [r4]
  34.    add r4, r4, #1
  35.    subs r7, r7, #1
  36.    bpl loop
  37. mov r8, #0
  38. strb r8, [r4]
  39.  
  40.  
  41.